package com.zhaojonhy.zhaopangwb.adapter;

import android.support.v4.view.PagerAdapter;
import android.view.View;
import android.view.ViewGroup;
import android.widget.GridView;

import java.util.List;

/**
 * Created by Administrator on 2016/9/28.
 */

public class EmotionPagerAdapter extends PagerAdapter {

    private List<GridView> gridViews ;
    public EmotionPagerAdapter(List<GridView> gridViews ) {
        this.gridViews = gridViews ;
    }

    @Override
    public int getCount() {
        return gridViews.size() ;
    }

    //当前布局和选中布局的判断
    @Override
    public boolean isViewFromObject(View arg0, Object arg1) {
        return arg0 == arg1 ;

    }

    //移除一个item布局
    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
        container.removeView(gridViews.get(position));
    }

    //创建一个item布局
    @Override
    public Object instantiateItem(ViewGroup container, int position) {
        container.addView(gridViews.get(position));
        //返回当前的布局
        return gridViews.get(position) ;
    }
}
